package com.heop.andyou.core;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.content.Context;
import android.opengl.GLSurfaceView;
import android.opengl.GLSurfaceView.Renderer;

public class GameView extends GLSurfaceView implements Renderer{
	IGameRenderable renderable;
	
	public GameView(Context context, IGameRenderable renderable) {
		super(context);
		this.renderable = renderable;
		setRenderer(this);
	}

	@Override
	public void onDrawFrame(GL10 gl) {
		renderable.update();
		renderable.render();
	}

	@Override
	public void onSurfaceChanged(GL10 gl, int width, int height) {
		renderable.resize(width, height);
	}

	@Override
	public void onSurfaceCreated(GL10 gl, EGLConfig config) {
		renderable.create();
	}

	@Override
	public void onPause() {
		super.onPause();
		renderable.pause();
	}

	@Override
	public void onResume() {
		super.onResume();
		renderable.resume();
	}
}
